package first.group.ssh.channel;

import first.group.ssh.writebuffer.ByteArrayContent;
import first.group.ssh.writebuffer.ByteBufferContent;
import first.group.ssh.writebuffer.WriteContent;
import java.io.IOException;
import java.nio.ByteBuffer;

public interface ChannelCallback {
    
    boolean shouldWrite();

    default void writeChannelData(ByteBuffer buffer) throws IOException {
        writeChannelData(new ByteBufferContent(buffer));
    }

    default void writeChannelData(byte[] data) throws IOException {
        writeChannelData(data, 0, data.length);
    }

    default void writeChannelData(byte[] data, int off, int len) throws IOException {
        writeChannelData(new ByteArrayContent(data, off, len, true));
    }
    
    void writeChannelData(WriteContent content) throws IOException;

    default void writeExtendedData(ByteBuffer buffer) throws IOException {
        writeExtendedData(new ByteBufferContent(buffer));
    }

    default void writeExtendedData(byte[] data) throws IOException {
        writeExtendedData(data, 0, data.length);
    }

    default void writeExtendedData(byte[] data, int off, int len) throws IOException {
        writeExtendedData(new ByteArrayContent(data, off, len, true));
    }
    
    void writeExtendedData(WriteContent content) throws IOException;
}
